I am using DOORS 9.4 to go through modules, and when I find an OLE in the Test Comment column, paste this into a Word document. |
Re: How do I "paste" the clipboard into Word? You need the OLE commands to do the following:
copy ole to clipboard
OleAutoObj oaoWord, oaoSelected
Do this: oaoWord = oleGetAutoObject("Word.Application")
or this: oleGet (oaoDoc, "Parent", oaoWord) // if you have "Document" handle oaoDoc
oleGet (oaoWord, "Selection", oaoSelected)
oleMethod(oaoSelection, "Paste")
|
Re: How do I "paste" the clipboard into Word? llandale - Fri Mar 15 12:01:41 EDT 2013 You need the OLE commands to do the following:
copy ole to clipboard
OleAutoObj oaoWord, oaoSelected
Do this: oaoWord = oleGetAutoObject("Word.Application")
or this: oleGet (oaoDoc, "Parent", oaoWord) // if you have "Document" handle oaoDoc
oleGet (oaoWord, "Selection", oaoSelected)
oleMethod(oaoSelection, "Paste")
Louie,
// Created 14-Mar-2013
/*
This works on either a single DVP or multiple DVPs within a folder.
This script opens up each file, and searches for Equipment List in a header
It puts the DVP Name and Equipment List into a file
Input - Single or multiple files
Output - Generates C:\DoorsLog\ExtractEquipList.txt (This file can be exported into Word using "^" as delimiters.)
*/
AttrDef ad
string strEquipmentList = "EQUIPMENT LIST"
const string WordDocument = "U:\\DoorsLog\\Test.docx"
int g_nInitialRun = 1
bool binitOnce = true
Module m
string strTemp
bool bSingleModule
string strWordApp = "Word.Application"
OleAutoObj oWord = null
OleAutoObj oDocuments = null
OleAutoObj oActiveDoc = null
OleAutoObj oSelection = null
OleAutoArgs oArgBlock = null
bool bToggleOn = true
Column CurrentColumn
string strNewLine = "\n"
string FORMAL = "Formal"
string PROJECT = "Project"
string FOLDER = "Folder"
string strFolderPath = "Folder Path:"
string strSpace = " "
string strBlank = ""
string strPathChangeMessage = "Note: To change this path, please close this dialog, then choose the new path in the Main DOORs Database. Then, restart this script."
void OLEResult(string s, string info)
{
if(s == null)
return
print info " -> "
print s strNewLine
}
void initWord(string tmplt, bool isDisplayed)
{
OleAutoObj oWord = oleGetAutoObject(strWordApp)
if(null oWord)
{
oWord = oleCreateAutoObject(strWordApp)
} // end if(null oWord)
// get document collection
OLEResult(oleGet(oWord, "Documents", oDocuments),"oDocuments")
if(null oDocuments)
{
ack "Unable to get Documents"
halt
} // end if(null oWorkbooks)
oArgBlock = create
put(oArgBlock, WordDocument)
OLEResult(oleMethod(oDocuments, "Add", oArgBlock),"oleMethod")
// get active document
OLEResult(oleGet(oWord, "ActiveWindow", oActiveDoc),"oActiveDoc")
if(null oActiveDoc)
{
ack "Unable to get active document"
halt
} // end if(null oWorkbook)
OLEResult(oleGet(oWord, "Selection", oSelection),"oSelection")
if(null oSelection)
{
ack "Unable to get Selection"
halt
} // end if(null oSelection)
OLEResult(olePut(oWord, "Visible", isDisplayed),"olePut")
} // initWord()
int ColumnCheck()
{
int nCount = 0
int nTestStatus = 0
Column col
for ad in m do
{
if ((ad.object) && (!ad.system))
{
col = column (nCount)
strTitle = title(col)
if (strTitle == "Test Comment")
{
CurrentColumn = col
break
} // end if (strTitle == strColumn)
nCount++
} // end if ((ad.object) && (!ad.system))
} // end for ad in mMod do
nTestStatus = nCount
return(nTestStatus)
} // ColumnCheck()
void Action(string ModuleName,bool bSingle)
{
string strObjectHeading = strBlank
bool HeadingFound = false
bool bValidModule = true
bool bEListFound = false
bool bDeactivate = false
bool bObjectTextOLE = false
Object o
int nTestCommentColumn = 0
int nOleExists = 0
bool bEquipmentListMissing = false
if (bSingle)
{
m = current
bool bInEditMode = canModify(m)
if (bInEditMode)
{
ModuleName = m."Name"
} // end if (bInEditMode)
else
{
ack "This module must be in edit mode!"
bValidModule = false
} // end else
} // end if (bSingle)
else
{
m = edit(ModuleName, false)
if (m == null)
bValidModule = false
} // end else
if (bValidModule)
{
Buffer HEADERBuf = create
Regexp Equip = regexp strEquipmentList
Object o = current
int nOleExists = 0
for o in m do
{
strObjectHeading = o."Object Heading"
HEADERBuf = strObjectHeading
if (bEListFound)
{
nOleExists = oleCount(o."Test Comment")
if (nOleExists == 1)
{
nTestCommentColumn = ColumnCheck()
strTemp = "oleActivate "oleActivate(o, CurrentColumn, 0)
print strTemp strNewLine
if (binitOnce) // needed for Folder choice
{
initWord(WordDocument, true)
binitOnce = false
} // end if (binitOnce)
//"oleCopy(o) works, oleCopy(o, CurrentColumn, nTestCommentColumn) results in "oleCopy OLE Index too large"
// but I do not want to copy the "Object Text" OLE, I want to copy the "Test Comment" OLE
strTemp = oleCopy(o, CurrentColumn, nTestCommentColumn)
print "oleCopy "strTemp " column "nTestCommentColumn strNewLine
OLEResult(oleMethod(oSelection, "Paste"),"Paste")
//bDeactivate = oleDeactivate(o, column nTestCommentColumn, 0) //-E- DXL: <Line:186> incorrect arguments for (=) -I- DXL: All done. Errors reported: 1. Warnings reported: 0.
//print "oleDeactivate "bDeactivate strNewLine
break
} // end if (nOleExists == 1)
else
{
bEquipmentListMissing = true
break
} // end else
} // end if (bEListFound)
else
{
HeadingFound = search(Equip,HEADERBuf,0) // search for Equipment List
if (HeadingFound)
{
print "Equipment List Found!" strNewLine
bEListFound = true
HeadingFound = false
} // end if (HeadingFound)
} // end else
} // end for o in m do
delete(HEADERBuf)
delete(Equip)
delete(oArgBlock)
if (bEquipmentListMissing)
ack "Equipment List Missing!"
if (!bSingle)
{
close (m, false)
} // end if (!bSingle)
} // end if (bValidModule)
} // end Action
void ProcessFolder(Folder fld)
{
Item itm
Module mod
string ModuleName
Skip skpItems = createString() // used to put items alphabetically sorted
// [1] Get items in the folder
for itm in fld do
{
if (!isDeleted(itm))
put(skpItems, name(itm), itm)
} // end for itm in fld do
// [2] process modules in the folder
for itm in skpItems do
{
if (type(itm) == FORMAL)
{
ModuleName = name(itm)
Action(ModuleName, bSingleModule)
} // end if (type(itm) == FORMAL)
} // for itm in skpItems do
// [3] recurse sub-folders and projects
for itm in skpItems do
{
if (type(itm) == FOLDER or type(itm) == PROJECT)
ProcessFolder(folder(fullName(itm)))
} // end for itm in skpItems do
delete(skpItems)
}
string SFFType[] = {"Single Module", "Folder"}
string strDialogTitle = "Check for Equipment List in Test Comment in module(s) " "3.2"
string strDefaultFolderPath = fullName current Folder
DB DialogBox = create(strDialogTitle)
DBE dbeLabel = label(DialogBox, "User shall be able to run a script which will extract Equipment List from a module(s).")
DBE TypeRadio = radioBox(DialogBox, "Select Module or Folder", SFFType, 0) // Default to folder
DBE dbeDefaultFolderPath = field(DialogBox, strFolderPath,"", 80,true) //Setting to true grays out this field
DBE dbePathLabel = label(DialogBox, strPathChangeMessage)
void Insert(DB DialogBox)
{
int nType = get TypeRadio
pragma runLim, 0 //disables the "Execution Timeout" dialog
if (nType == 0)
{
bSingleModule = true
Action(strSpace, bSingleModule)
} // end if (nType == 0)
else
{
bSingleModule = false
void DoFolder(Folder fld)
{
ProcessFolder(fld)
} DoFolder(current Folder)
} // end else
if (showing DialogBox)
{
hide(DialogBox)
destroy(DialogBox) // free up resources now
DialogBox = null
} // end if (showing DialogBox)
} // Insert
apply(DialogBox, "Extract Equipment List in module", Insert)
set(dbeDefaultFolderPath, strDefaultFolderPath) // Update into the folder path area in dialog
show DialogBox // No text can appear after here as it will not be executed!!!!!!!!!
Attachments attachment_14958201_Capture.PNG |